﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ColorPicker
{
    public partial class SettingsForm : Form
    {

        public delegate void ConfirmHandler(int i, bool b);
        public event ConfirmHandler onConfirm;
        private int WindowBehaviourConfig;

        public SettingsForm(int i, bool b)
        {
            InitializeComponent();

            checkBox_isShowMagnifier.Checked = b;
            WindowBehaviourConfig = i;
            switch (i)
            {
                case ConfigHelper.TAG_IS_FOLLOW_MOUSE:
                    radioButton_isFollowMouse.Checked = true;
                    break;
                case ConfigHelper.TAG_IS_MINIMIZE:
                    radioButton_isMinimize.Checked = true;
                    break;
                case ConfigHelper.TAG_NONE_OF_ALL:
                    radioButton_noneOfAll.Checked = true;
                    break;
                default:
                    break;
            }
        }

        private void button_confirm_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.setting_window_behaviour = WindowBehaviourConfig;
            Properties.Settings.Default.setting_is_show_magnifier = checkBox_isShowMagnifier.Checked;
            Properties.Settings.Default.Save();
            onConfirm(WindowBehaviourConfig, checkBox_isShowMagnifier.Checked);
            Close();
        }

        private void button_cancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void radioButton_isFollowMouse_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton_isFollowMouse.Checked)
            {
                WindowBehaviourConfig = ConfigHelper.TAG_IS_FOLLOW_MOUSE;
            }
        }

        private void radioButton_isMinimize_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton_isMinimize.Checked)
            {
                WindowBehaviourConfig = ConfigHelper.TAG_IS_MINIMIZE;
            }
        }

        private void radioButton_noneOfAll_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton_noneOfAll.Checked)
            {
                WindowBehaviourConfig = ConfigHelper.TAG_NONE_OF_ALL;
            }
        }
    }
}
